import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

public class DatabasePopulator extends WebPage {

	public DatabasePopulator() {
		
		List<User> users = findAllCustomers();
		
		add(new ListView<User>("searchResults", users) {
			private static final long serialVersionUID = 1L;
			protected void populateItem(ListItem<User> item) {
				User user = item.getModelObject();
				item.add(new Label("id", String.valueOf(user.getUserId())));
				item.add(new Label("firstName", user.getFirstName()));
				item.add(new Label("lastName", user.getLastName()));
				
			}
		});
	}

	private List<User> findAllCustomers() {
		List<User> users = new ArrayList<User>();
		User user = null;
		for (int i = 0; i < 1; i++) {
			user = new User(1, "Henri", "IsTheGreatest");
			users.add(user);
		}
		return users;
	}

	class User {
		
		private int userId;
		private String firstName;
		private String lastName;
		
		public int getUserId() {
			return userId;
		}
		public void setUserId(int userId) {
			this.userId = userId;
		}
		public String getFirstName() {
			return firstName;
		}
		public void setFirstName(String firstName) {
			this.firstName = firstName;
		}
		public String getLastName() {
			return lastName;
		}
		public void setLastName(String lastName) {
			this.lastName = lastName;
		}
		
		public User(int userId, String firstName, String lastName) {
			this.userId = userId;
			this.firstName = firstName;
			this.lastName = lastName;
		}
	}
	
}
